/*
 * @Author: zhouxiaofan
 * @Date: 2021-11-20 20:58:10
 * @LastEditTime: 2021-11-20 22:17:28
 * @LastEditors: Please set LastEditors
 * @Description: 用户评论接口
 * @FilePath: /blogServe/src/controller/comment.controller.js
 */
const service = require('../service/comment.service.js')

class CommentController {
  async create(ctx, next) {
    const { momentId, content } = ctx.request.body;
    const { id } = ctx.user;
    const result = await service.create(momentId, content, id);
    ctx.body = {
      code: 200,
      msg: "发表评论成功",
      result
    }
  }

  async reply(ctx, next) {
    const { momentId, content } = ctx.request.body;
    const { commentId } = ctx.params;
    const { id } = ctx.user;
    const result = await service.reply(momentId, content, id, commentId);
    ctx.body = {
      code: 200,
      msg: "回复评论成功",
      result
    }
  } 
}

module.exports = new CommentController();